# import pandas as pd
# import matplotlib.pyplot as plt
# from mlxtend.preprocessing import TransactionEncoder
# from mlxtend.frequent_patterns import apriori, association_rules
#
# # 加载蘑菇数据集
# url = "https://archive.ics.uci.edu/ml/machine-learning-databases/mushroom/agaricus-lepiota.data"
# # 如果数据集不在本地，可以直接使用 URL 加载
# data = pd.read_csv(url, header=None)
#
# # 设定列名为英文
# columns = [
#     "class", "cap-shape", "cap-surface", "cap-color", "bruises", "odor", "gill-attachment",
#     "gill-spacing", "gill-size", "gill-color", "stalk-shape", "stalk-root", "stalk-surface-above-ring",
#     "stalk-surface-below-ring", "stalk-color-above-ring", "stalk-color-below-ring", "veil-type",
#     "veil-color", "ring-number", "ring-type", "spore-print-color", "population", "habitat"
# ]
# data.columns = columns
#
# # 将数据集转换成适合 Apriori 算法的格式
# data_encoded = pd.get_dummies(data)
#
# # 将数据集中的所有列转换为布尔类型
# data_encoded = data_encoded.astype(bool)
#
# # 使用 Apriori 算法获取频繁项集（调整支持度阈值）
# frequent_itemsets = apriori(data_encoded, min_support=0.9, use_colnames=True)  # 调整支持度阈值
# print(frequent_itemsets)
# # 根据频繁项集生成关联规则（调整置信度阈值）
# rules = association_rules(frequent_itemsets, metric="confidence", min_threshold=0.6)  # 调整置信度阈值
# print(rules)
# # 创建一个字典来映射列名
# column_mapping = {column: column.split('_')[-1] for column in data_encoded.columns}
#
# # 对关联规则中的先导项和后继项进行列名的转换
# rules['antecedents'] = rules['antecedents'].apply(lambda x: [column_mapping[i] for i in list(x)])
# rules['consequents'] = rules['consequents'].apply(lambda x: [column_mapping[i] for i in list(x)])
#
# # 创建一个字典来统计特征列与置信度的关系
# feature_confidence = {}
# for index, row in rules.iterrows():
#     for feature in row['antecedents']:
#         feature_confidence.setdefault(feature, []).append(row['confidence'])
#     for feature in row['consequents']:
#         feature_confidence.setdefault(feature, []).append(row['confidence'])
#
# # 对特征列与置信度的关系进行可视化：柱状图展示置信度
# plt.figure(figsize=(12, 6))
# plt.bar(feature_confidence.keys(), [sum(values) / len(values) for values in feature_confidence.values()], color='skyblue', alpha=0.8)
# plt.xlabel('Feature')
# plt.ylabel('Average Confidence')
# plt.title('Relationship between Feature and Average Confidence')
# plt.xticks(rotation=45, ha='right')
# plt.show()
print(frozenset(['r','z','h','j','p']))